layui.config({
    base: "Scripts/"
}).use(['form', 'layer', 'layedit'], function () {
    var form = layui.form,
		layer = layui.layer,
		$ = layui.jquery;
    //自定义验证规则
    form.verify({
        UserName:function (value) {
            if (value.length == 0) {
                return '请输入用户名/工号';
            }
        }
      , UserPass: [/(.+){6,12}$/, '密码必须6到12位']      
      , VerificationCode: function (value) {
          if (value.length == 0) {
              return '请输入验证码';
          }
      }
    });
    //跟新验证码
    var loginManager = {
        updateVerificationCode: function () {
            
            var data = new Data().getTime();
                //alert("测试");
                
                
                alert(data)
        },
        loginSubmit: function (data) {

            $.ajax({
                type: "POST",
                url: "/Account/Login",//发送请求  
                data: data.field,
                dataType: "json",
                success: function (result) {
                    if (result.State == 1)
                        layer.alert(result.Message, { icon: 7 });
                    else
                        layer.msg(result.Message, { icon: 1 }, function (index) {
                            location.href = '/Main/Index';
                            layer.close(index);
                        });
                }
            });
        }
    };

    $("#validateCode").click(function () {
        this.src = 'ValidateCode/GetValidateCode?v=' + new Date().getTime();
    });

    //监听提交
    form.on('submit(loginForm)', function (data) {
        loginManager.loginSubmit(data);
        return false;
    });

});



